%% Demonstrate key features of the dotsQueryableEye class family.
clear
clear classes
clc

% choose one of the dotsQueryableEye implementations

% generates random data formatted like eye-like data
eyeClass = 'dotsQueryableEyeRandom';

% uses ASL hardware and the as() mex function
%eyeClass = 'dotsQueryableEyeASL';

% uses Eyelink hardware and the Eyelink Toolbox
%eyeClass = 'dotsQueryableEyeEyelink';

% create the eyetracker object
qm = dotsTheQueryablesManager.theObject;
et = qm.newObject(eyeClass);

% depending on the type of eyetracker class,
%   may need to configure data scaling

% a rectagle described in raw data units
%   to scale data into aritrary units
%et.inputRect = [-13.49 10.95 13.49.*2 -10.95.*2]*100;

% the same rectagle described in graphical units
%   to scale data into graphical (or other) units
et.xyRect = [-12 -10 24 20];

% reinitialize the object to take any reconfiguration into account
et.initialize;

%% classify the scaled data
% create a dotsPhenomenon representing a small rectangle in the center of
% the eyetracer's xyRect
temp = et.getPhenomenonTemplate;
inBox = dotsPhenomenon.rectangle(temp, 'xPos', 'yPos', [-2 -2 4 4], 'in');

% classify this phenomenon with the string "in the box"
et.addClassificationInGroupWithRank(inBox, 'in the box', 'sandbox', 1);
et.activeClassificationGroup = 'sandbox';

%% Plot live data
% the eye position cursor should change color
%   when the eye is in the box specified above
et.plotData;

% uncomment to save data
% et.logAllData;
% et.logQueryOutputs;
% topsDataLog.writeDataFile;
% et.flushData;